
#ifndef _SERVER_H_
#define _SERVER_H_

#include <string>

// forward declarations
struct event_base;
struct evhttp;

class Server {
public:
	static Server &instance();

	int start();
	void stop();

private:
	Server();
	Server(const Server &);
	void operator=(const Server &);
	~Server();

	static Server *_instance;

	bool is_master;
	int lockfile_fd;
	volatile bool _running; // we change it via signal

	event_base *ebase;
	evhttp *ehttp;

	void daemonize();
	void setupEvents();
	void setupSignals() const;

	void spawnWorkers(int num);
};

#endif
